﻿using System;
using System.Text;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
using Telerik.Windows.Documents.Utilities;

namespace TestComparer
{  
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private readonly ComparisonWriter writer;

        public MainWindow()
        {
            InitializeComponent();
            this.writer = new ComparisonWriter(this.shitsGoHere, this.darjavataGoHere);
            this.writer.Tolerance = 0;

            Matrix m = new Matrix(1, 2, 3, 4, 5, 6);

            Matrix m1 = m;
            Matrix m2 = m;

            m1 = m1.TranslateMatrix(4, 5);
            m2.Translate(4, 5);
            writer.WriteComparison(m1, m2, "Translate test");

            m1 = m;
            writer.WriteComparison(m1, m, "Returning to normal state");
            m2 = m;
            writer.WriteComparison(m2, m, "Returning to normal state");

            m1 = m1.MultiplyBy(m);
            m2.Append(m);
            writer.WriteComparison(m1, m2, "Multiplication test");

            m1 = m;
            m2 = m;
            m1 = m1.ScaleMatrixAt(10, 3, 0, 0);
            m2.Scale(10, 3);
            writer.WriteComparison(m1, m2, "Simple scaling");

            m1 = m;
            m2 = m;
            m1 = m1.ScaleMatrixAt(10, 3, 5, 7);
            m2.Translate(-5, -7);
            m2.Scale(10, 3);
            m2.Translate(5, 7);
            writer.WriteComparison(m1, m2, "Complex scaling");
            Matrix m3 = m;
            m3.ScaleAt(10, 3, 5, 7);
            writer.WriteComparison(m2, m3, "Complex scaling darjavata samo");
            writer.WriteComparison(m1, m3, "Complex scaling az i darjavata");

            m1 = m;
            m2 = m;
            m1 = m1.RotateMatrix(32);
            m2.Rotate(32);
            writer.WriteComparison(m1, m2, "Simple rotation");

            m1 = m;
            m2 = m;
            m1 = m1.RotateMatrixAt(32, 5, 7);
            m2.RotateAt(32, 5, 7);
            writer.WriteComparison(m1, m2, "Complex rotation");

            m1 = m;
            m2 = m;
            m1 = m1.InverseMatrix();
            m2.Invert();
            writer.WriteComparison(m1, m2, "Inverse matrix");
        }

        private void CopyText_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder builder = new StringBuilder();
            foreach (Inline inline in this.darjavataGoHere.Inlines)
            {
                Run run = inline as Run;
                if (run != null)
                {
                    builder.Append(run.Text);
                }

                LineBreak lineBreak = inline as LineBreak;
                if(lineBreak != null)
                {
                    builder.AppendLine();
                }
            }

            string text = builder.ToString();
            System.Windows.Clipboard.SetText(text);
        }
    }
}
